package com.kingdee.openimport.patch_service.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.kingdee.openimport.patch_service.model.Patch;
import com.kingdee.openimport.patch_service.service.IPatchRedisService;
import lombok.Data;

/**
 * 补丁文件的VO对象
 * Created by Niki on 2018/5/10 9:47
 */
@Data
public class PatchVO {
    private String type ;
    private String className ;
    private byte[] patchFile ;

    @JsonIgnore
    public static PatchVO patchToVO(Patch patch, IPatchRedisService patchRedisService) {
        PatchVO vo = new PatchVO();
        vo.setType(patch.getType());
        vo.setClassName(patch.getClassName());

        String id = patch.getId();
        byte[] patchFile = patchRedisService.getPatchByte(id);
        vo.setPatchFile(patchFile);

        return vo;
    }
}
